/*
 * @ClassName language_provider.dart
 * @Description 全局语言状态管理
 * @Author SuPeiSen
 * @Date 2020/7/14 10:38
 */

import 'package:flutter/foundation.dart';
import 'package:flutter_su/common/fun.dart';
import 'package:flutter_su/enum/language_type.dart';

class LanguageProvider with ChangeNotifier{

  LanguageType _languageType;

  LanguageProvider.init(){
    this._languageType = LanguageType.chinese;
  }

  final Map<LanguageType, Map<ContentType, Map<String, String>>> _map = {
    LanguageType.chinese: {
      ContentType.loginRegister : {
        "inputEmail": "请输入你的注册邮箱",
        "emailNoRegister": "此邮箱尚未注册，请重新输入",
        "next": "下一步",
        "inputPassword": "请输入你的密码",
        "passwordError": "密码有误，请重新输入",
        "goToBitBro": "进入BitBro",
        "inputRegisterEmail": "请输入邮箱",
        "inputRegisterPassword": "请输入密码",
        "inputRegisterPasswordSecond": "再次确定密码",
        "inputRegisterPasswordError": "两次密码不相等",
        "emailFormatError": "请输入正确的邮箱格式",
        "null" : "",
        "forgetPassword" : "忘记密码",
        "inputEmailToSendCode" : "请输入接受验证码的邮箱",
        "inputEmailCode" : "请输入验证码",
        "inputNewPassword" : "请输入新密码（不能少于8位）",
        "inputSecondNewPassword" : "请确认新密码（不能少于8位）",
        "emailMust": "请输入邮箱",
        "password": "请输入密码",
        "getEmailCode" : "发送验证码",
        "language": "En",
        "countryList": "国家",
        "retry": "重试",
      },
      ContentType.show : {
        "success" : "成功",
        "unSuccess": "失败",
        "loading": "请稍等",
        "mushBeCompany": "身份只能是公司",
      },
      ContentType.audit : {
        "type": "类型",
        "identity": "身份",
        "nationality": "国籍",
        "userName": "姓名",
        "userId": "身份证",
        "companyName": "公司名称",
        "companyAddress": "公司地址",
        "companyNameEn": "Company Name",
        "companyAddressEn": "Company Address",
        "companyCertificate": "公司证书",
        "passport": "护照",
        "idCardFront": "身份证正面",
        "idCardBack": "身份证反面",
      },
      ContentType.agent: {
        "signTheContract": "签署合约",
        "sign": "签署",
        "recommendInvestors": "推荐投资者",
        "interested": "感兴趣",
        "FinancingStage": "融资阶段",
        "NumberOfInvestorsHaveSubmitted": "已提交</br>投资者数量",
        "NumberOfProjectsInterested": "已接收</br>投资者数量",
        "YouHaveSubmittedYourApplication": "您已提交签约申请",
        "AfterTheApplicationIsProcessed": "申请获处理后，请于待签约项目中签署确认条款",
        "InvestorType": "投资者类型",
        "InvestorCompany": "投资者公司",
        "InvestorName": "投资者姓名",
        "PleaseEnterTheCompanyName": "请输入公司名称",
        "PleaseEnterInvestorName": "请输入投资者姓名",
        "PleaseEnterRegion": "请输入地区",
        "Confirm": "确认提交",
        "WaitingForInvestmentBankReview": "等待投行审核",
        "RejectedItems": "拒签项目",
        "ToIPFS": "合约同步到IPFS需要时间，如不能打开请稍后再试",
        "ToIPF": "合约同步到IPFS需要时间",
        "CheckContract": "查看合约",
        "signedProject": "成功签约项目",
        "InvestorRegion": "投资者地区",
        "InvestorPhone": "投资者电话",
        "InvestorMailbox": "投资者邮箱",
        "ProjectsToBeConfirmedByInvestors": "待投资者确认项目",
        "InvestmentBankToReviewTheProject": "待投行审核项目",
        "InvestmentBankConfirmed": "投行已确认",
        "TheInvestmentBankHasConfirmed": "投行已经确认你所推荐的投资者，请尽快发送邮件给投资者",
        "SendEmailToInvestors": "发送邮件到投资者",
        "InvitationToBeSentToInvestors": "待发送邀请邮件给投资者",
        "InvestmentBank": "投资银行",
        "InvestmentProject": "投资项目",
        "Reminder": "提示",
        "FurtherInformation": "了解详情",
        "SentSuccessfully": "发送成功",
        "PleaseWaitForInvestorsToConfirmAndImproveTheInformation": "请等待投资者确认并完善资料",
        "EmailFormatIsIncorrect": "邮箱格式不正确"
      },
      ContentType.common: {
        "potentialInvestors": "潜在投资者要求",
        "pleaseGetCode": "请发送邮件获取验证码",
        "NotFound": "没有找到",
        "UploadJPG": "请上传 jpg 格式图片",
        "PRE-IPO": "PRE-IPO",
        "IPO": "IPO",
        "network": "网络异常",
        "SendCode": "发送验证码",
        "Code": "验证码",
        "pleaseCode": "请输入验证码",
        "NoMore": "没有更多了",
        "forgetPassword": "忘记密码",
        "Investor": "投资者",
        "Middleman": "中间人",
        "ProjectParty": "项目方",
        "Category": "类型",
        "review": "审核",
        "SwitchLanguage": "切换语言",
        "isYes": "是",
        "isNo": "否",
        "Determine": "确定",
        "Cancel": "取消",
        "ProjectDetails": "项目详情",
        "individual": "个人",
        "company": "公司",
        "Industry": "行业",
        "ProjectDescription": "项目简介",
        "region": "地区",
        "CompanyName": "公司名称",
        "Currency": "币种",
        "FundingAmount": "集资金额",
        "ContactNumber": "联系电话",
        "Email": "电子邮箱",
        "Reminder": "提醒",
        "PleaseEnterTheSearchKeyword": "请输入搜索关键词",
        "Home": "首页",
        "MyProjectS": "我的项目",
        "ConnectedItems": "已连接项目",
        "Contacts": "联络",
        "ContractStatus": "签约状态",
        "ME": "我的",
        "ElectronicSignature": "电子签名",
        "Rewrite": "重写",
        "Submit": "提交",
        "PleaseSignInTheBox": "请在方框内签名",
        "TheItemNoLongerExists": "项目已不存在,请确认是否已刪除",
        "Pending": "待处理",
        "ToBeSigned": "待签约",
        "PendingItems": "待处理项目",
        "ToBeSignedProject": "待签约项目",
        "RefusalToSignProject": "拒绝签约项目",
        "InvestmentBankHasRejected": "投行已拒绝",
        "SignedForChain": "已签约待上链",
        "ChainedForRecommendation": "已上链待推荐",
        "PendingReview": "待审核项目",
        "ReviewedPending": "已审核待发送",
        "ToBeConfirmedByInvestors": "待投资者确认",
        "SignedContract": "签约成功",
        "RejectedProject": "已拒绝项项目",
        "Rejected": "已拒绝",
        "InvestorHasRejected": "投资者已拒绝",
        "RegisterNewAccount": "注册新账号",
        "AccountAndPasswordCannotBeEmpty": "账号和密码不能为空，请输入",
        "RequestFailed": "请求失败，点击重新加载",
        "InformationOfContractedInvestors": "签约投资者资料",
        "ItemsOfInterest": "感兴趣项目",
        "AllAreas": "全部地区",
        "YouChooseToLogOut": "你选择退出当前登录账户,是否继续",
        "LogOut": "退出登录",
        "login": "登录",
        "PassWord": "密码",
        "changePassword": "修改密码",
        "NewPassword": "新密码",
        "ConfirmPassword": "确认密码",
        "PasswordsEnteredTwiceAreInconsistent": "两次密码输入不一致",
        "PleaseFillInTheNewPassword": "请填写新密码",
        "ProjectScreening": "项目筛选",
        "SelectAll": "全选",
        "ApplicationTime": "申请时间",
        "ApplicationProject": "申请项目",
        "ApplicationMiddleman": "申请中间人",
        "InvestorName": "投资者名称",
        "SigningTime": "签约时间",
        "AlreadyHaveAnAccount": "已有账号,前往登录",
        "register": "注册",
        "registrationSuccess": "注册成功",
        "NextLogin": "下一步请登录",
        "Identity": "身份",
        "Nationality": "国籍",
        "PersonalName": "姓名",
        "IdentificationNumber": "身份证号码",
        "IDCardFront": "身份证正面",
        "IDCardBack": "身份证背面",
        "passport": "护照",
        "CertificateNumber": "证件号码",
        "PleaseNationality": "请输入国籍",
        "PleasePersonalName": "请输入姓名",
        "PleasePerCertificateNumber": "请输入证件号码",
        "Certificate": "公司证书",
        "YourReviewFailed": "很抱歉,您的审核没通过",
        "WaitForReview": "请等待审核",
        "YourInformationHasBeenSubmitted": "你的资料已提交,请等待审核",
        "ApplyAgain": "再次申请",
        "NetworkError": "网络异常，请稍后再试"
      },
      ContentType.contractWords: {
        "pleaseEnter": "请输入",
        "submit": "提交",
        "UploadFailed": "上传失败",
        "PleaseEnterRepresentativeRights": "请输入代表权益",
        "PleaseEnterName": "请输入名称",
        "PleaseEnterTheTitle": "请输入职称",
        "PleaseReturnToCompleteInformation": "请返回完成信息填写",
        "NextConfirmAndUploadToBlockChain": "正在上载到区块链,请耐心等候",
        "ConfirmAndUploadToBlockChain": "正在上载到区块链",
        "UploadTakesAboutOneMinute": "上传大概需要1分钟，请耐心等候"
      },
      ContentType.investor: {
        "MyProfile": "我的资料",
        "CompleteMaterial": "完善资料",
        "Refuse": "拒绝",
        "NextRegisterANewAccount": "下一步注册新账号",
        "IfYouHaveAnAccountPleaseLogIn": "如已有账号，请直接登陆",
        "WhetherToDecline": "是否拒绝",
        "RefuseSuccessfully": "拒绝成功",
        "InformationOfContractedInvestors": "签约投资者资料",
        "InvestorCompanyAddress": "投资者公司地址",
        "InvestorInterest": "投资者兴趣",
        "IndustryOfInterest": "感兴趣行业",
        "PleaseEnterTheNameOfTheInvestorCompany": "请输入投资者公司名称",
        "PleaseEnterInvestorRegion": "请输入投资者地区",
        "InvestorRegion": "投资者地区",
        "PleaseEnterInvestorName": "请输入投资者姓名",
        "PleaseEnterInvestorPhone": "请输入投资者电话",
        "InvestorPhone": "投资者电话",
        "PleaseEnterInvestorEmail": "请输入投资者邮箱",
        "InvestorEmail": "投资者邮箱",
        "EmailFormatIsIncorrect": "电子邮箱格式不正确",
        "PleaseEnterInvestorAddress": "请输入投资者地址",
        "InvestorAddress": "投资者地址",
        "PleaseSelectIndustry": "请选择感兴趣行业",
        "PleaseLoginAndOperate": "请登录后操作",
        "ItemsToBeConfirmed": "待确认项目"
      },
      ContentType.projectOwner: {
        "PleaseEnterContractContent": "请输入合同内容",
        "YourRegistrationReviewDidNotPass": "您的注册审核不通过，请前往我的-个人审核里修改",
        "BackToMyProject": "返回我的项目",
        "ConnectedItems": "已连接项目",
        "SerialNumber": "序号",
        "recommendPerson": "推荐人",
        "recommendCode": "请输入推荐码",
        "InvestorInformation": "投资者资料",
        "ViewProjectDetails": "查看项目详情",
        "SeedRound": "种子轮",
        "AngelWheel": "天使轮",
        "ARound": "A轮",
        "BRound": "B轮",
        "CRound": "C轮",
        "SigningTime": "签约成功时间",
        "IntermediaryInformation": "中间人资料",
        "ConfirmInvestor": "确认投资人",
        "interested": "感兴趣",
        "MiddlemanType": "中间人类型",
        "MiddlemanName": "中间人名称",
        "ReviewItems": "待审核项目",
        "ThisItemHasBeenDeleted": "该项目已删除",
        "PleaseConfirmTheOperation": "请确认操作",
        "CooperationIntentionHasBeenSent": "已发送合作意向，等待中间人发送邀请邮件给投资者",
        "Contacts": "联络人"
      }
    },
    LanguageType.english: {
      ContentType.loginRegister : {
        "inputEmail": "Please enter your email address",
        "emailNoRegister": "This mailbox has not been registered, please re-enter it!",
        "next": "next",
        "inputPassword": "Please enter your password",
        "passwordError": "Wrong password, please re-enter it",
        "goToBitBro": "goToBitBro",
        "inputRegisterEmail": "Please enter a mailbox",
        "inputRegisterPassword": "Please enter the password",
        "inputRegisterPasswordSecond": "Confirm the password again",
        "inputRegisterPasswordError": "The passwords are not equal twice",
        "emailFormatError": "Please enter the correct mailbox format",
        "forgetPassword" : "Forget password",
        "inputEmailToSendCode" : "Please enter the email address to accept the verification code",
        "inputEmailCode" : "Please enter the verification code.",
        "inputNewPassword" : "Please enter a new password (no less than 8 digits)",
        "inputSecondNewPassword" : "Please confirm the new password (no less than 8 digits)",
        "getEmailCode" : "emailCode",
        "language": "中",
        "countryList": "Country",
        "retry": "重试",
      },
      ContentType.show : {
        "success" : "success",
        "unSuccess": "unSuccess",
        "loading": "loading",
        "mushBeCompany": "Identity mush be Company",
      },
      ContentType.audit : {
        "type": "UserType",
        "identity": "UserIdentity",
        "nationality": "Nationality",
        "userName": "UserName",
        "userId": "IdCard",
        "companyName": "CompanyName",
        "companyAddress": "CompanyAddress",
        "companyCertificate": "CompanyCertificate",
        "passport": "Passport",
        "idCardFront": "IdCardFront",
        "idCardBack": "IdCardBack",
      },
      ContentType.agent: {
        "signTheContract": "sign the contract",
        "sign": "sign",
        "recommendInvestors": "Recommend Investors",
        "interested": "interested",
        "FinancingStage": "Financing Stage",
        "NumberOfInvestorsHaveSubmitted": "Submission of Investors",
        "NumberOfProjectsInterested": "Number of investors received",
        "YouHaveSubmittedYourApplication": "You have submitted the application successfully",
        "AfterTheApplicationIsProcessed": "Once approval by bank, please sign the contract",
        "InvestorType": "Investor Type",
        "InvestorCompany": "Investor company",
        "InvestorName": "Investor Name",
        "PleaseEnterTheCompanyName": "PleaseEnter The CompanyName",
        "PleaseEnterInvestorName": "Please Enter Investor Name",
        "PleaseEnterRegion": "Please Enter Region",
        "Confirm": "Confirm",
        "WaitingForInvestmentBankReview": "Waiting approval by bank",
        "RejectedItems": "Reject",
        "ToIPFS": "It takes some time to synchronize the contract to IPFS. If fail to open, please try it later",
        "ToIPF": "It takes some time to synchronize the contract to IPFS",
        "CheckContract": "View",
        "signedProject": "Signed Project",
        "InvestorRegion": "Investor Region",
        "InvestorPhone": "Investor Phone",
        "InvestorMailbox": "Email Address",
        "ProjectsToBeConfirmedByInvestors": "Waiting investors to confirm",
        "InvestmentBankToReviewTheProject": "Under review by bank",
        "InvestmentBankConfirmed": "Confirmed by bank",
        "TheInvestmentBankHasConfirmed": "The Investment Bank Has Confirmed",
        "SendEmailToInvestors": "Send Email To Investors",
        "InvitationToBeSentToInvestors": "Invitation To Be Sent To Investors",
        "InvestmentBank": "Investment Bank",
        "InvestmentProject": "Investment Project",
        "Reminder": "Reminder",
        "FurtherInformation": "Further Information",
        "SentSuccessfully": "Sent Successfully",
        "PleaseWaitForInvestorsToConfirmAndImproveTheInformation": "Please Wait For Investors To Confirm and Complete",
        "EmailFormatIsIncorrect": "Email Format Is Incorrect"
      },
      ContentType.common: {
        "potentialInvestors": "Potential investors",
        "pleaseGetCode": "Please send email to get code",
        "NotFound": "Not Found",
        "UploadJPG": "Please upload picture in JPG format",
        "PRE-IPO": "PRE-IPO",
        "IPO": "IPO",
        "network": "Network exception",
        "SendCode": "Send",
        "Code": "Code",
        "pleaseCode": "Please enter code",
        "NoMore": "No more",
        "forgetPassword": "Forgot password",
        "Investor": "Investor",
        "Middleman": "Middleman",
        "ProjectParty": "Project Party",
        "Category": "Category",
        "review": "review Status",
        "SwitchLanguage": "Switch Language",
        "isYes": "Yes",
        "isNo": "No",
        "Determine": "Confirm",
        "Cancel": "Cancel",
        "ProjectDetails": "Project Details",
        "individual": "Individual",
        "company": "Company",
        "Industry": "Industry",
        "ProjectDescription": "Project Description",
        "region": "Region",
        "CompanyName": "Company Name",
        "Currency": "Currency",
        "FundingAmount": "Fund Raising",
        "ContactNumber": "Contact Number",
        "Email": "Email Address",
        "Reminder": "Reminder",
        "PleaseEnterTheSearchKeyword": "Please Enter The Keyword",
        "Home": "Home",
        "MyProjectS": "Projects",
        "ConnectedItems": "Connection",
        "Contacts": "Contacts",
        "ContractStatus": "Status",
        "ME": "Me",
        "ElectronicSignature": "Electronic Signature",
        "Rewrite": "Rewrite",
        "Submit": "Submit",
        "PleaseSignInTheBox": "Please sign In The Box",
        "TheItemNoLongerExists": "Cannot find the project, because it has been deleted",
        "Pending": "Pending",
        "ToBeSigned": "To Be Signed",
        "PendingItems": "Pending Projects",
        "ToBeSignedProject": "To Be Signed Project",
        "RefusalToSignProject": "Refusal Project",
        "InvestmentBankHasRejected": "Investment Bank Has Rejected",
        "SignedForChain": "Signed For Chain",
        "ChainedForRecommendation": "Chained For Recommendation",
        "PendingReview": "Pending Review",
        "ReviewedPending": "To Be Sent an invitation",
        "ToBeConfirmedByInvestors": "To Be Confirmed By Investors",
        "SignedContract": "Signed Contract",
        "RejectedProject": "Rejected Project",
        "Rejected": "Has been Rejected",
        "InvestorHasRejected": "Investor Has Rejected",
        "AccountAndPasswordCannotBeEmpty": "Account and Password can not be Empty",
        "RequestFailed": "Request Failed",
        "InformationOfContractedInvestors": "Information Of Investors",
        "ItemsOfInterest": "Items Of Interest",
        "AllAreas": "All Regions",
        "YouChooseToLogOut": "Log out?",
        "LogOut": "Log Out",
        "login": "Log In",
        "PassWord": "Password",
        "changePassword": "Change Password",
        "NewPassword": "New Password",
        "ConfirmPassword": "Confirm Password",
        "PasswordsEnteredTwiceAreInconsistent": "Passwords entered twice are inconsistent",
        "PleaseFillInTheNewPassword": "Please Enter the new password",
        "ProjectScreening": "Projects fliter",
        "SelectAll": "Select All",
        "ApplicationTime": "Time Of Application",
        "ApplicationProject": "Project Of Application",
        "ApplicationMiddleman": "Middleman Of Application",
        "InvestorName": "Name of Investor",
        "SigningTime": "Time Of Signing",
        "AlreadyHaveAnAccount": "Go for login",
        "register": "sign Up",
        "registrationSuccess": "register Success",
        "NextLogin": "log In",
        "Identity": "Identity",
        "Nationality": "Nationality",
        "PersonalName": "Name",
        "IdentificationNumber": "Identification Numbers",
        "IDCardFront": "The front of IDCard",
        "IDCardBack": "The Back of IDCard",
        "passport": "Passport",
        "CertificateNumber": "Certificate Number",
        "PleaseNationality": "Please enter your nationality",
        "PleasePersonalName": "Please enter your name",
        "PleasePerCertificateNumber": "Please enter your nertificate number",
        "Certificate": "Certificate",
        "YourReviewFailed": "Your Review Failed",
        "WaitForReview": "Wait For Review",
        "YourInformationHasBeenSubmitted": "Your information has been submitted,please wait",
        "ApplyAgain": "Fill in again",
        "NetworkError": " Network is out of service"
      },
      ContentType.contractWords: {
        "pleaseEnter": "please enter",
        "submit": "Submit",
        "UploadFailed": "Upload failed",
        "PleaseEnterRepresentativeRights": "Please enter your representative",
        "PleaseEnterName": "Please enter your name",
        "PleaseEnterTheTitle": "Please enter your title",
        "PleaseReturnToCompleteInformation": "Please Return To Complete Information",
        "NextConfirmAndUploadToBlockChain": "Uploading To Blockchain,please wait",
        "ConfirmAndUploadToBlockChain": "Uploading To Blockchain",
        "UploadTakesAboutOneMinute": "Please wait with patient, about 1 minute..."
      },
      ContentType.investor: {
        "MyProfile": "My Profile",
        "CompleteMaterial": "Complete form",
        "Refuse": "Refuse",
        "NextRegisterANewAccount": "Next register a New Account",
        "IfYouHaveAnAccountPleaseLogIn": "Please Log in if you have an account",
        "WhetherToDecline": "Refuse or not",
        "RefuseSuccessfully": "Refuse Successfully",
        "InformationOfContractedInvestors": "Information Of  Investors",
        "InvestorCompanyAddress": "Investor Company Address",
        "InvestorInterest": "Investor Interests",
        "IndustryOfInterest": "Industry Of Interest",
        "PleaseEnterTheNameOfTheInvestorCompany": "Please enter the name of the investor company",
        "PleaseEnterInvestorRegion": "Please enter investor Region",
        "InvestorRegion": "Region",
        "PleaseEnterInvestorName": "Please enter investor name",
        "PleaseEnterInvestorPhone": "Please Enter Contact Number",
        "InvestorPhone": "Contact Number",
        "PleaseEnterInvestorEmail": "Please Enter Investor Email",
        "InvestorEmail": "Investor Email",
        "EmailFormatIsIncorrect": "Email Format is incorrect",
        "PleaseEnterInvestorAddress": "Please Enter Investor Address",
        "InvestorAddress": "Investor Address",
        "PleaseSelectIndustry": "Please Select Industry",
        "PleaseLoginAndOperate": "Please login and Operate",
        "ItemsToBeConfirmed": "Items to be confirmed"
      },
      ContentType.projectOwner: {
        "PleaseEnterContractContent": "Please enter contract content",
        "YourRegistrationReviewDidNotPass": "Your Registration Review Did Not Pass",
        "BackToMyProject": "Back to My Project",
        "ConnectedItems": "Connected Items",
        "SerialNumber": "No.",
        "recommendPerson": "recommendPerson",
        "recommendCode": "Enter the recommendation code",
        "InvestorInformation": "Investors Info",
        "ViewProjectDetails": "See Project Details",
        "SeedRound": "Seed round",
        "AngelWheel": "Angel round",
        "ARound": "A round",
        "BRound": "B round",
        "CRound": "C round",
        "SigningTime": "Signing time",
        "IntermediaryInformation": "Intermediary Information",
        "ConfirmInvestor": "Confirm Investor",
        "interested": "Interest",
        "MiddlemanType": "Intermediary type",
        "MiddlemanName": "Intermediary name",
        "ReviewItems": "To be Reviewed items",
        "ThisItemHasBeenDeleted": "This item has been deleted",
        "PleaseConfirmTheOperation": "Please confirm the operation",
        "CooperationIntentionHasBeenSent": "Cooperation intention has been sent,please wait"
      }
    }
  };

  // get和set方法
  LanguageType get getLanguageType => this._languageType;
  void setLanguageType(LanguageType type){
    this._languageType = type;
    notify();
  }

  // 切换语言
  void switchLanguageType(){
    this._languageType = this._languageType == LanguageType.chinese
        ? LanguageType.english : LanguageType.chinese;
    notify();
  }

  // 通过语言类型和key获取对应要显示的文字
  String getText({@required ContentType contentType, @required String key}){
    return this._map[this._languageType][contentType][key] ?? "";
  }

  void notify(){
    notifyListeners();
  }
}

